package com.oraclejava.bookmark;

import com.oraclejava.phonehistory.R;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Browser;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;

public class ContentProvider_bookmarkActivity extends Activity {
	private static String[] mProjections = new String[] {
			Browser.BookmarkColumns.TITLE, 
			Browser.BookmarkColumns.URL };
	ListView listView1;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		initialize();

		Cursor cursor = getContentResolver().query(
				Browser.BOOKMARKS_URI, 
				mProjections, 
				Browser.BookmarkColumns.BOOKMARK + "=?",
				new String[]{"1"}, 
				Browser.BookmarkColumns.VISITS + " Desc");
		startManagingCursor(cursor);

		ListAdapter adapter = new SimpleCursorAdapter(this,
				android.R.layout.simple_list_item_2, cursor, 
				new String[] {
				Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL }, 
				new int[] {
						android.R.id.text1, android.R.id.text2 });
		listView1.setAdapter(adapter);
	}

	private void initialize() {
		setContentView(R.layout.main);
		listView1 = (ListView) findViewById(R.id.listView1);

	}
}